﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.OjbectPool
{
    public abstract class BasePooledObjectFactory<T> : IPooledObjectFactory<T>
    {
        /// <summary>
        ///  Creates an object instance, to be wrapped in a <see cref="IPooledObject"/>.
        /// <p>This method <strong>must</strong> support concurrent, multi-threaded
        ///activation.</p>
        /// </summary>
        /// <returns>an instance to be served by the pool</returns>
        public abstract T Create();
        /// <summary>
        /// Wrap the provided instance with an implementation of <see cref="IPooledObject"/>
        /// </summary>
        /// <param name="obj">obj the instance to wrap</param>
        /// <returns>the provided instance, wrapped by a <see cref="IPooledObject"/></returns>
        public abstract IPooledObject<T> Wrap(T obj);

        public IPooledObject<T> MakeObject()
        {
            return Wrap(Create());
        }

        public void DestroyObject(IPooledObject<T> p)
        {
             
        }

        public bool ValidateObject(IPooledObject<T> p)
        {
            return true;
        }

        public void ActivateObject(IPooledObject<T> p)
        {
            
        }

        public void PassivateObject(IPooledObject<T> p)
        {
             
        }
    }
}
